<?php
class msetmenu extends CI_Model{
	var $menu = "set_menu";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_menu,$nama_menu,$urutan_menu,$enable_menu)
	{
		$this->id_menu= $id_menu;
		$this->nama_menu= $nama_menu;
		$this->urutan_menu= $urutan_menu;
		$this->enable_menu= $enable_menu;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->menu, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$this->db->where('enable_menu', '1');
		$query = $this->db->get($this->menu);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_menu'=>$this->id_menu,
			'nama_menu'=>$this->nama_menu,
			'urutan_menu'=>$this->urutan_menu,
			'enable_menu'=>$this->enable_menu
		);
		return $this->db->insert($this->menu, $arrayData);
	}
	
	function update($id_menu)
	{
		$arrayData = array(
			'nama_menu'=>$this->nama_menu,
			'urutan_menu'=>$this->urutan_menu,
			'enable_menu'=>$this->enable_menu
		);
		$this->db->where('id_menu', $id_menu);
		return $this->db->update($this->menu, $arrayData);
	}
        
	function remove($id_menu)
	{
		$this->db->where('id_menu', $id_menu);
		return $this->db->delete($this->menu);
	}	
	
	function detail($id_menu)
	{
		$this->db->where('id_menu', $id_menu);
		$query = $this->db->get($this->menu);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('urutan_menu',$name);
		$query = $this->db->get($this->menu);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>